package com.guaoran.interview.spring.autowired.controller;

import com.guaoran.interview.spring.autowired.service.InjectService;
import com.guaoran.interview.spring.autowired.service.NamedService;
import com.guaoran.interview.spring.autowired.service.QualifierService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.inject.Inject;
import javax.inject.Named;

/**
 * @author : 孤傲然
 * @description : Inject
 * @date :2020/1/3 16:09
 */
@RestController
public class InjectController {
    private InjectService injectService;

    @Inject
    public void setInjectService(InjectService injectService){
        this.injectService = injectService;
    }

    // 使用 qualifier 查找
    @Inject
    @Named("secondQualifierService")
    private QualifierService qualifierService;

    // 使用 primary 的 firstQualifierService
    @Inject
    private QualifierService service;

    @Inject
    private NamedService namedService;
    @GetMapping("/named")
    public String qualifier(){
        namedService.toString();
        return qualifierService.toString() +"--"+service.toString();
    }
}
